import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    port: 3000,
    proxy: {
      // Admin API 代理 - 代理 /api/v1 到后端
      '/api/v1': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        rewrite: (path) => {
          console.log('🔄 API Proxy - Original path:', path);
          // 直接转发，不做重写
          console.log('🔄 API Proxy - Forwarded path:', path);
          return path;
        }
      },
    },
  },
})
